#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2021/7/2 16:33
# @Author    :cjw
import allure

from app_wework_po.util.log import logger
from app_wework_po.setting import ELEMENT_YML
from app_wework_po.base.base_page import BasePage
from app_wework_po.util.file_operator import YmlOperator


class AddMemberPage(BasePage):
    """添加成员页面"""
    # 添加元素定位数据到locators
    BasePage.locators.update(YmlOperator(ELEMENT_YML['amp']).data)

    def goto_edit_member_by_manual(self):
        """手动输入添加，跳转到添加成成员页面"""
        from app_wework_po.page.edit_member_page import EditMemberPage

        with allure.step(msg := '点击"手动输入添加"，进入手动输入添加成员页面'):
            logger.info(msg)
            self.tap(self.manual_input)
        return EditMemberPage(self.driver)

    def find_toast_text(self):
        """获取新增成员成功的toast文本"""
        text = self.toast_text
        with allure.step(msg := f'获取toast提示信息：{text}'):
            logger.info(msg)
        return text
